import {createRouter, createWebHashHistory, RouteRecordRaw} from "vue-router";

export const asyncRoutes: Array<RouteRecordRaw> = [
  {
    path: "/login",
    name: "login",
    component: () => import("@/views/login/login.vue")
  },
  {
    path: "/:pathMath(.*)",
    component: () => import("@/views/notFound/notFound.vue")
  },
  {
    path: "/userCenter",
    name: "userCenter",
    redirect: "/userCenter/userinfo",
    component: () => import("@/layout/Layout.vue"),
    meta: {
      title: "个人中心",
      hiddenChildren: true,
      hidden: true
    },
    children: [
      {
        path: "userinfo",
        name: "userinfo",
        component: () => import("@/views/userCenter/userinfo.vue"),
        meta: {
          title: "个人中心"
        }
      }
    ]
  }
];

export const constantRoutes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "homePage",
    redirect: "/home",
    component: () => import("@/layout/Layout.vue"),
    meta: {
      title: "首页",
      icon: "home-outlined",
      hiddenChildren: true
    },
    children: [
      {
        path: "home",
        name: "home",
        component: () => import("@/views/home/home.vue"),
        meta: {
          title: "首页"
        }
      }
    ]
  },
  {
    path: "/customerArchives",
    name: "customerArchives",
    redirect: "/customerArchives/memberManagement",
    component: () => import("@/layout/Layout.vue"),
    meta: {
      title: "客户档案",
      icon: "team-outlined",
      hiddenChildren: false
    },
    children: [
      {
        path: "memberManagement",
        name: "memberManagement",
        component: () =>
          import("@/views/customerArchives/memberManagement.vue"),
        meta: {
          title: "会员管理"
        }
      },
      {
        path: "memberTag",
        name: "memberTag",
        component: () => import("@/views/customerArchives/memberTag.vue"),
        meta: {
          title: "会员标签"
        }
      },
      {
        path: "subjectMessage",
        name: "subjectMessage",
        component: () => import("@/views/customerArchives/subjectMessage.vue"),
        meta: {
          title: "主体信息"
        }
      },
      {
        path: "subjectMessageCheckPage",
        name: "subjectMessageCheckPage",
        component: () =>
          import("@/views/customerArchives/subjectMessageCheckPage.vue"),
        meta: {
          title: "主体信息审核"
        }
      },
      {
        path: "userGrade",
        name: "userGrade",
        component: () => import("@/views/customerArchives/userGrade.vue"),
        meta: {
          title: "用户等级"
        }
      }
    ]
  },
  {
    path: "/merchandise",
    name: "merchandise",
    redirect: "/merchandise/classification",
    component: () => import("@/layout/Layout.vue"),
    meta: {
      title: "商品信息",
      icon: "shopping-outlined",
      hiddenChildren: false
    },
    children: [
      {
        path: "classification",
        name: "classification",
        component: () => import("@/views/merchandise/classification.vue"),
        meta: {
          title: "商品分类"
        }
      },
      {
        path: "commodity",
        name: "commodity",
        component: () => import("@/views/merchandise/commodity.vue"),
        meta: {
          title: "商品管理"
        }
      },
      {
        path: "postage",
        name: "postage",
        component: () => import("@/views/merchandise/postage.vue"),
        meta: {
          title: "邮费管理"
        }
      }
    ]
  },
  {
    path: "/orderManagement",
    name: "orderManagement",
    redirect: "/orderManagement/evaluationManagement",
    component: () => import("@/layout/Layout.vue"),
    meta: {
      title: "订单管理",
      icon: "profile-outlined",
      hiddenChildren: false
    },
    children: [
      {
        path: "evaluationManagement",
        name: "evaluationManagement",
        component: () =>
          import("@/views/orderManagement/evaluationManagement.vue"),
        meta: {
          title: "评价管理"
        }
      },
      {
        path: "exportingInformation",
        name: "exportingInformation",
        component: () =>
          import("@/views/orderManagement/exportingInformation.vue"),
        meta: {
          title: "导出日志信息"
        }
      },
      {
        path: "orderManagementList",
        name: "orderManagementList",
        component: () =>
          import("@/views/orderManagement/orderManagementList.vue"),
        meta: {
          title: "订单管理"
        }
      }
    ]
  },
  {
    path: "/afterSales",
    name: "afterSales",
    redirect: "/afterSales/afterSalesApply",
    component: () => import("@/layout/Layout.vue"),
    meta: {
      title: "售后订单",
      icon: "whatsAppOutlined",
      hiddenChildren: false
    },
    children: [
      {
        path: "afterSalesApply",
        name: "afterSalesApply",
        component: () => import("@/views/afterSales/afterSalesApply.vue"),
        meta: {
          title: "售后申请"
        }
      }
    ]
  },
  {
    path: "/discount",
    name: "discount",
    redirect: "/discount/discountList",
    component: () => import("@/layout/Layout.vue"),
    meta: {
      title: "优惠券",
      icon: "MoneyCollectOutlined",
      hiddenChildren: false
    },
    children: [
      {
        path: "discountList",
        name: "discountList",
        component: () => import("@/views/discount/discountList.vue"),
        meta: {
          title: "优惠券列表"
        }
      }
    ]
  },
  {
    path: "/finance",
    name: "finance",
    redirect: "/finance/journalAccount",
    component: () => import("@/layout/Layout.vue"),
    meta: {
      title: "财务模块",
      icon: "PayCircleOutlined",
      hiddenChildren: false
    },
    children: [
      {
        path: "journalAccount",
        name: "journalAccount",
        component: () => import("@/views/finance/journalAccount.vue"),
        meta: {
          title: "资金流水"
        }
      }
    ]
  },
  {
    path: "/configCenter",
    name: "configCenter",
    redirect: "/configCenter/platform/comp",
    component: () => import("@/layout/Layout.vue"),
    meta: {
      title: "配置中心",
      icon: "setting-outlined"
    },
    children: [
      {
        path: "platform",
        name: "platform",
        redirect: "/configCenter/platform/comp",
        component: () => import("@/views/base/base.vue"),
        meta: {
          title: "平台管理"
        },
        children: [
          {
            path: "comp",
            name: "comp",
            component: () => import("@/views/configCenter/platform/comp.vue"),
            meta: {
              title: "组件配置"
            }
          },
          {
            path: "dataResource",
            name: "dataResource",
            component: () =>
              import("@/views/configCenter/platform/dataResource.vue"),
            meta: {
              title: "数据资源"
            }
          },
          {
            path: "dataPermission",
            name: "dataPermission",
            component: () =>
              import("@/views/configCenter/platform/dataPermission.vue"),
            meta: {
              title: "数据权限"
            }
          },
          {
            path: "processTemplate",
            name: "processTemplate",
            component: () =>
              import("@/views/configCenter/platform/processTemplate.vue"),
            meta: {
              title: "审批流程模板"
            }
          },
          {
            path: "approveExamination",
            name: "approveExamination",
            component: () =>
              import("@/views/configCenter/platform/approveExamination.vue"),
            meta: {
              title: "业务流程配置"
            }
          },
          {
            path: "menu",
            name: "menu",
            component: () => import("@/views/configCenter/platform/menu.vue"),
            meta: {
              title: "菜单管理"
            }
          }
        ]
      },
      {
        path: "organization",
        name: "organization",
        redirect: "/configCenter/organization/institution",
        component: () => import("@/views/base/base.vue"),
        meta: {
          title: "组织架构"
        },
        children: [
          {
            path: "institution",
            name: "institution",
            component: () =>
              import("@/views/configCenter/organization/institution.vue"),
            meta: {
              title: "机构管理"
            }
          },
          {
            path: "position",
            name: "position",
            component: () =>
              import("@/views/configCenter/organization/position.vue"),
            meta: {
              title: "职位管理"
            }
          }
        ]
      },
      {
        path: "auth",
        name: "auth",
        redirect: "/configCenter/auth/role",
        component: () => import("@/views/base/base.vue"),
        meta: {
          title: "权限管理"
        },
        children: [
          {
            path: "role",
            name: "role",
            component: () => import("@/views/configCenter/auth/role.vue"),
            meta: {
              title: "角色管理"
            }
          },
          {
            path: "people",
            name: "people",
            component: () => import("@/views/configCenter/auth/people.vue"),
            meta: {
              title: "用户管理"
            }
          }
        ]
      }
    ]
  },
  {
    path: "/login",
    name: "login",
    component: () => import("@/views/login/login.vue")
  },
  {
    path: "/:pathMath(.*)",
    component: () => import("@/views/notFound/notFound.vue")
  },
  {
    path: "/userCenter",
    name: "userCenter",
    redirect: "/userCenter/userinfo",
    component: () => import("@/layout/Layout.vue"),
    meta: {
      title: "个人中心",
      hiddenChildren: true,
      hidden: true
    },
    children: [
      {
        path: "userinfo",
        name: "userinfo",
        component: () => import("@/views/userCenter/userinfo.vue"),
        meta: {
          title: "个人中心"
        }
      }
    ]
  }
];

const router = createRouter({
  history: createWebHashHistory(),
  routes: asyncRoutes
});

export default router;
